package me.jessyan.armscomponent.app.app;

import android.app.Activity;
import android.content.Context;

import androidx.multidex.MultiDex;

import com.jess.arms.base.BaseApplication;

import java.util.LinkedList;
import java.util.List;

/**
 * package: me.jessyan.armscomponent.app.app
 * author: Taozebi
 * datetime: 2021/8/8 17:44
 * describe: describe of this class
 */
public class StarApp extends BaseApplication {
    private List<Activity> activityList = new LinkedList<Activity>();
    private static StarApp instance;

    public static StarApp getInstance() {
        if(null == instance) {
            instance = new StarApp();
        }
        return instance;
    }

    //添加Activity到容器中
    public void addActivity(Activity activity)  {
        activityList.add(activity);
    }

    //遍历所有Activity并finish
    public void exit() {
        for(Activity activity:activityList) {
            activity.finish();
        }
        activityList.clear();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
//        startStrictMode();
        //初始化Dex
        MultiDex.install(base.getApplicationContext());
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }
}
